﻿using System;
using System.Collections;
using System.Collections.Generic;
using Socium.Domain.Persons;
using System.Linq;

namespace Socium.Domain.Tests.Testings {
	[Serializable]
	public class AnswersCollection : IEnumerable<Answer> {
		readonly ICollection<Answer> _items = new LinkedList<Answer>();
		readonly Testing _testing;

		internal AnswersCollection(Testing testing) {
			_testing = testing;
		}

		public void Add(Answer answer) {
			_items.Add(answer);
		}

		public IEnumerable<Answer> this[Person person] {
			get {
				return _items.Where(a => a.Person == person);
			}
		}

		public IEnumerator<Answer> GetEnumerator() {
			return _items.GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator() {
			return GetEnumerator();
		}
	}
}
